import Vue from 'vue'
import axios from 'axios'
import request from '@/utils/request'
import conf from './apiConf'

// export function fetchUserData() {
//     return request.get('https://api.github.com/users/woai3c')
// }

// export function getMens() {
//     return this.$http.get('/getmenus')
// }

// export function searchUser(content) {
//     return request.get('http://www.kirrito.top/admin/searchUser', {
//         content
//     })
// }
axios.defaults.baseURL = window.location.origin
axios.defaults.headers['token'] = localStorage.getItem('token')
// Vue.prototype.$axios = axios
Vue.prototype.Api = {
    Login({
        params
    }) {
        return axios.post(conf.Login + params)
    },
    searchUser(str) {
        // axios.defaults.headers['token'] = localStorage.getItem('token')
        return axios.get(conf.searchUser, {
            params: {
                content: str
            }
        })
    },
    UpdateUserInfo(obj) {
        var params = new URLSearchParams();
        params.append('id', obj.u_id);
        params.append('name', obj.u_name);
        params.append('nick', obj.u_nick);
        params.append('phone', obj.u_phone);
        params.append('email', obj.u_email);
        params.append('sex', obj.u_sex);
        params.append('pwd', obj.u_pwd);
        params.append('status', obj.u_status)
        params.append('rId', obj.r_id)
        return axios.post(conf.UpdateUserInfo, params);
    },
    Register(obj) {
        var params = new URLSearchParams();
        return axios.post(conf.Register, params)
    }

}
